function lefmenu_Tip(content, cat, time){
	Tip('<div style=\"text-align:left;\"><i style=\"color:#2A75C5\">'+cat+'</i><br />'+content+'<br /><span style="color:#aaaaaa;">'+COREJS._getJsLang('_VAO_LUC')+': '+time+'</span></div>', SHADOW, true, SHADOWCOLOR, '#ffbbcc', BORDERCOLOR, '#555555', BGCOLOR, '#ffffe1', WIDTH, 200);
}
function toUnformattedNumber(id_row){
	document.getElementById(id_row).value=document.getElementById(id_row+'_').value;
}
$(function() {
    $( "#dialogPhieuThu" ).dialog({
        autoOpen: false,
        height: 260,
        width:420,
        modal: true
    });
    $(".openppphieuthu").click(function(){
        $( "#dialogPhieuThu" ).dialog( "open" );
    })
});
$(function() {
    $( "#dialogPhieuChi" ).dialog({
        autoOpen: false,
        height: 260,
        width:420,
        modal: true
    });
    $(".openppphieuchi").click(function(){
        $( "#dialogPhieuChi" ).dialog( "open" );
    })
});
function check_add_phieu_thu(){
	khachhang     = document.getElementById('khachhang_t');
	sotien     = document.getElementById('sotient');
	sotien_     = document.getElementById('sotient_');		
	// bieu thuc kiem tra rong
	re = /^(\s)*$/i;
	str = RegExp(re);
	if(str.test(khachhang.value)){
		alert(COREJS._getJsLang('ALERT_KH_HD'));
		khachhang.select();
		return false;
	}
	if(str.test(sotien_.value)){
		alert(COREJS._getJsLang('_BAN_CHUA_NHAP_SO_TIEN_THU'));
		sotien.select();
		return false;
	}
	if(sotien_.value<=0){
		alert(COREJS._getJsLang('_BAN_PHAI_NHAP_SO_TIEN_THU_DUONG'));
		sotien.select();
		return false;
	}
	else{
		var getFormValues = $('#frmAddPhieuThu').serialize();
		var urlaction = COREJS._getJsLang('URL')+"/modules/hopdong/ThuChiIndex/AddPhieuThu?"+getFormValues;
		$.getJSON(urlaction,null,function(data){
			if(data == 1){
				window.location = COREJS._getJsLang('URL')+"/modules/hopdong/ThuChiIndex?pt=1";
			}
		});
		
		khachhang.value='';
		sotien.value='';
		sotien_.value='';
		document.getElementById('Kha_Id_t').value='';
		document.getElementById('ghi_chu_pthu').value='';
		$( "#dialogPhieuThu" ).dialog( "close" );
	 }
}
function check_add_phieu_chi(){
	khachhang     = document.getElementById('khachhang_c');
	sotien     = document.getElementById('sotien');
	sotien_     = document.getElementById('sotien_');		
	// bieu thuc kiem tra rong
	re = /^(\s)*$/i;
	str = RegExp(re);
	if(str.test(khachhang.value)){
		alert(COREJS._getJsLang('ALERT_KH_HD'));
		khachhang.select();
		return false;
	}
	if(str.test(sotien_.value)){
		alert(COREJS._getJsLang('_BAN_CHUA_NHAP_SO_TIEN_CHI'));
		sotien.select();
		return false;
	}
	if(sotien_.value<=0){
		alert(COREJS._getJsLang('_BAN_PHAI_NHAP_SO_TIEN_CHI_DUONG'));
		sotien.select();
		return false;
	}
	else{
		var getFormValues = $('#frmAddPhieuChi').serialize();
		var urlaction = COREJS._getJsLang('URL')+"/modules/hopdong/ThuChiIndex/AddPhieuThu?"+getFormValues;
		$.getJSON(urlaction,null,function(data){
			if(data == 1){
				window.location = COREJS._getJsLang('URL')+"/modules/hopdong/ThuChiIndex?pc=1";
			}
		});

		khachhang.value='';
		sotien.value='';
		sotien_.value='';
		document.getElementById('Kha_Id_c').value='';
		document.getElementById('gc_phieu_chi').value='';
		$( "#dialogPhieuChi" ).dialog( "close" );
	 }
}
function xoa_hopdong(id,kt,khaid){
	conf = confirm(COREJS._getJsLang('_ALERT_XOA_HOP_DONG'));
	if(conf){
		window.location = COREJS._getJsLang('URL')+"/modules/hopdong/edit/deleteHOPDONG?KhaId="+khaid+'&Hdo_Id='+id+'&kt='+kt;
	}
}
$(function() {
    $( "#dialogAddHDTT" ).dialog({
        autoOpen: false,
        height: 270,
        width:420,
        modal: true
    });
    $(".openppaddthanhtoan").click(function(){
        $( "#dialogAddHDTT" ).dialog( "open" );
    })
});
function open_popupThanhToan_jq(id){
		$(function() {
			$( ".dialogThanhToan_"+id ).dialog({
				autoOpen: false,
				height: 270,
				width:420,
				modal: true
			});
		   
				$( ".dialogThanhToan_"+id ).dialog( "open" );
			
		});
}
$(function() {
    $( "#dialogAddHDCP" ).dialog({
        autoOpen: false,
        height: 270,
        width:420,
        modal: true
    });
    $(".openppaddchiphi").click(function(){
        $( "#dialogAddHDCP" ).dialog( "open" );
    })
});
function open_popupChiPhi_jq(id){
		$(function() {
			$( ".dialogChiPhi_"+id ).dialog({
				autoOpen: false,
				height: 300,
				width:420,
				modal: true
			});
		   
				$( ".dialogChiPhi_"+id ).dialog( "open" );
			
		});
}
function delete_donhang(id,tl,khaid){
	if(tl == 1){
		conf = confirm(COREJS._getJsLang('_ALERT_XOA_HANG_TRA_LAI'));
	}
	else{
		conf = confirm(COREJS._getJsLang('_ALERT_XOA_DON_HANG'));
	}
	if(conf){
		window.location = COREJS._getJsLang('URL')+"/modules/hopdong/edit/deleteDONHANG?DhaId="+id+'&TL='+tl+'&KhaId='+khaid;
	}
}